<template>
 <div>
        <div class="chattitle">
                    <p class="title" v-if="selectedChatSession">客服:{{selectedChatSession.serviceName}} ID:{{selectedChatSession.serviceId}}</p>
        </div>
        <div class="message" >       
            <div v-if="selectedChatSession">
                <ul class="chatbox">
                    <li v-for="msg in selectedChatSession.msg">
                        <p class="time">{{msg.date|time}}</p>
                        <p class="record"></p>
                        <div class="main" :class="{self:msg.self}">
                            <!-- <img class="avatar" width="30" height="30" :src="msg.self ? user.img : session.user.img" /> -->
                            <div class="text">{{msg.content}}</div>
                        </div>
                    </li>
                    <!-- <p v-if="!selectedChat.alive" style="color:darkgrey;text-align:center;font-style: italic;">- -  已离线  - -</p> -->
                </ul>
            </div>        
        </div>
    </div>
</template>
<script>
import store from '../store'
import { mapState } from 'vuex'

export default {
    name:'ServicePanel',
    data(){
        return {
            content:'',
        }
    },
    methods:{
        removeChat:function(selectService){
            //store.state.chatList.splice(store.state.chatList.indexOf(selectChat),1)
        },
    },
    computed:mapState({
        selectService:state=>state.selectService,
        selectedChatSession:state=>state.serviceList.find(session=>session.serviceId===state.selectService)
    })
}
</script>
<style scoped lang="less">
.chattitle{
        height: 55px;
        text-align: center;
        p{
            margin: 0 auto;
            background-color: #b4d892;
            //margin:10px 10px 10px 10px;
            height: 21px;
            width: 450px;
        }
    }
.message {
    padding: 10px 15px;
    overflow-y: scroll;
    height: 365px;
    li {
        margin-bottom: 15px;
        list-style: none;
    }
    .time {
        margin: 7px 0;
        text-align: center;

        > span {
            display: inline-block;
            padding: 0 18px;
            font-size: 12px;
            color: #fff;
            border-radius: 2px;
            background-color: #dcdcdc;
        }
    }
    .avatar {
        float: left;
        margin: 0 10px 0 0;
        border-radius: 3px;
    }
    .text {
        display: inline-block;
        position: relative;
        padding: 0 10px;
        max-width: ~'calc(100% - 40px)';
        min-height: 30px;
        line-height: 2.5;
        font-size: 12px;
        text-align: left;
        word-break: break-all;
        background-color: #fafafa;
        border-radius: 4px;

        &:before {
            content: " ";
            position: absolute;
            top: 9px;
            right: 100%;
            border: 6px solid transparent;
            border-right-color: #fafafa;
        }
    }

    .self {
        text-align: right;

        .avatar {
            float: right;
            margin: 0 0 0 10px;
        }
        .text {
            background-color: #b2e281;

            &:before {
                right: inherit;
                left: 100%;
                border-right-color: transparent;
                border-left-color: #b2e281;
            }
        }
    }
}
</style>